<template>
    <div class="block">
        <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 12, 16, 21]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
        </el-pagination>
    </div>
</template>

<script>
export default {
    name:"CommonFooter",
    props:['pageData'],//父组件传来的（初始）值
    watch:{
      pageData:{
        immediate:true,
        handler(newValue){
          this.total=newValue.total;//总条目数
          this.pageSize=newValue.size;
          this.currentPage=newValue.current; 
        }
      }
    },
    methods: {
      handleSizeChange(val) {
        this.pageSize=val;//每页显示条目数√
        this.currentPage=1;
        this.$emit("currentPage",this.currentPage);
        this.$emit("pageSize",this.pageSize);
      },
      handleCurrentChange(val) {
        this.currentPage=val;//当前页数√ 
        this.$emit("currentPage",this.currentPage);
      },
    },
    data() {
      return {
        currentPage:0,
        pageSize:0,
        total:0,
      };
    }
}
</script>

<style>

</style>